Grab fridays data
library(RPostgreSQL)
## Loading required package: DBI
library(getPass)
## Warning: package 'getPass' was built under R version 3.5.3
# set driver name
driver_name <- dbDriver(drvName = "PostgreSQL")
# establish database connection
db <- DBI::dbConnect(driver_name,
dbname = "sebi",
host = "192.168.0.12",
port = 5432,
user = "sebi",
password = getPass("Enter Password:")
)
## Please enter password in TK window (Alt+Tab)
# our query
sql_query_string <- "SELECT * FROM watchlist_data WHERE scrape_date = '2022-06-24';"
# combination of our connnection stuff and our query stuff
res <- dbSendQuery(db, sql_query_string)
# fetch our data query from the database and return a dataframe
data_pull <- dbFetch(res)
# clear our query results
dbClearResult(res)
## [1] TRUE
# politely disconnect from the database
dbDisconnect(db)
## [1] TRUE
source("payout_functions.R")
# create a mid price
data_pull$mid <- (data_pull$bid + data_pull$ask) / 2
# lets grab the QQQ Aug 19th calls
sample_chain <- data_pull[data_pull$underlying_ticker == "QQQ" & data_pull$expiration_date == as.Date("2022-08-19"),]
long_call_strike <- 340
short_call_strike <- 335
long_put_strike <- 265
short_put_strike <- 270
sample_iron_condor <- iron_condor_profit(
sample_chain,
long_call_strike,
short_call_strike,
long_put_strike,
short_put_strike
)
sample_covered_call <- covered_call_profit(sample_chain, 330)
lineplot_profit(sample_iron_condor, "Sample Iron Condor")
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
## This version of bslib is designed to work with shiny version 1.6.0 or higher.